Add code to get container type from groundspeak extensions to GPX.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 6 Feb 2003 23:48:35 +0000 (23:48 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 6 Feb 2003 23:48:35 +0000 (23:48 +0000)
gpsbabel/defs.h
gpsbabel/gpx.c

index 1c9fe09d085216cef67cffbdedba53993c78c04a..201257a4c1a4bd18d95be4cf2f0909781c0c00e4 100644 (file)
@@ -93,8 +93,18 @@ typedef enum {
        gt_suprise
 } geocache_type;
 
+typedef enum {
+       gc_unknown = 0,
+       gc_micro,
+       gc_other,
+       gc_regular,
+       gc_large,
+       gc_virtual
+} geocache_container;
+
 typedef struct {
        geocache_type type;
+       geocache_container container;
        int diff; /* (multiplied by ten internally) */
        int terr; /* (likewise) */
 } geocache_data ;
index 52d98027e5edecc9694a9966095c4ebf7b8b68e6..46b3ac25b5a2b54166a42de52e337a9da359c2db 100644 (file)
@@ -34,6 +34,7 @@ static int in_url;
 static int in_icon;
 static int in_urlname;
 static int in_gs_type;
+static int in_gs_container;
 static int in_gs_diff;
 static int in_gs_terr;
 static int in_gs_log;
@@ -304,6 +305,11 @@ gpx_start(void *data, const char *el, const char **attr)
                in_something_else++;
                start_something_else( el, attr );
        } 
+       else if (strcmp(el, "groundspeak:container") == 0) {
+               in_gs_container++;
+               in_something_else++;
+               start_something_else( el, attr );
+       } 
        else if (strcmp(el, "groundspeak:difficulty") == 0) {
                in_gs_diff++;
                in_something_else++;
@@ -341,6 +347,19 @@ gs_type_mapping{
        { gt_multi, "Multi-Cache" },
        { gt_virtual, "Virtual cache" }
 };
+
+struct
+gs_container_mapping{
+       geocache_container type;
+       const char *name;
+} gs_container_map[] = {
+       { gc_other, "Unknown" },
+       { gc_micro, "Micro" },
+       { gc_regular, "Regular" },
+       { gc_large, "Large" },
+       { gc_virtual, "Virtual" }
+};
+
 static
 geocache_type
 gs_mktype(char *t)
@@ -356,6 +375,21 @@ gs_mktype(char *t)
        return gt_unknown;
 }
 
+static
+geocache_container
+gs_mkcont(char *t)
+{
+       int i;
+       int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
+
+       for (i = 0; i < sz; i++) {
+               if (0 == case_ignore_strcmp(t, gs_container_map[i].name)) {
+                       return gs_container_map[i].type;
+               }
+       }
+       return gt_unknown;
+}
+
 static void
 gpx_end(void *data, const char *el)
 {
@@ -400,6 +434,9 @@ gpx_end(void *data, const char *el)
                if (in_wpt && in_gs_type && !in_gs_log) {
                        wpt_tmp->gc_data.type = gs_mktype(cdatastr);
                }
+               if (in_wpt && in_gs_container) {
+                       wpt_tmp->gc_data.container = gs_mkcont(cdatastr);
+               }
                if (in_wpt && in_gs_diff) {
                        sscanf(cdatastr, "%f", &x);
                        wpt_tmp->gc_data.diff = x * 10;
@@ -439,6 +476,10 @@ gpx_end(void *data, const char *el)
                in_gs_type--;
                in_something_else--;
                end_something_else();
+       } else if (strcmp(el, "groundspeak:container") == 0) {
+               in_gs_container--;
+               in_something_else--;
+               end_something_else();
        } else if (strcmp(el, "groundspeak:difficulty") == 0) {
                in_gs_diff--;
                in_something_else--;
@@ -479,6 +520,7 @@ gpx_cdata(void *dta, const XML_Char *s, int len)
                        (in_wpt && in_url) ||
                        (in_wpt && in_urlname) ||
                        (in_wpt && in_gs_type) || 
+                       (in_wpt && in_gs_container) || 
                        (in_wpt && in_gs_diff) || 
                        (in_wpt && in_gs_terr) || 
                        (in_wpt && in_icon) ||